package com.chang.product.web;

import com.chang.product.service.SkuInfoService;
import com.chang.product.vo.SkuItemVo;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;

/**
 * @author: changzhenxi
 * @date: 2024年11月13日 14:35
 * @Version: 1.0
 * @description:
 */
@Controller
public class ItemController {

    @Resource
    SkuInfoService skuInfoService;

    /**
     * @param: [skuId, model]
     * @return: java.lang.String
     * @author changzhenxi
     * @date 2024/11/13 - 14:38
     * @history 2024/11/13 - 14:38 changzhenxi create
     */
    @GetMapping("/{skuId}.html")
    public String skuItem(@PathVariable("skuId") Long skuId, Model model) {
        System.out.println("准备查询" + skuId + "商品详情");
        SkuItemVo skuItemVo = skuInfoService.getSkuItem(skuId);
        model.addAttribute("item", skuItemVo);
        return "item";
    }
}
